{% extends "siem/base.html" %}

{% block sub-title %}Log Events | {% endblock %}

{% block content-main %}

<h1>Log Events</h1>
<p>Search fields accept regular expressions (except date/time fields).</p>

<form method="get" action="{% url 'siem:logevent_search' %}">
    <table class="searchform">
        <tr>
            <td class="searchform">Log Source:
                <input type="text" value="{{ log_source_filter }}" name="log_source_filter"/>
            </td>
            <td class="searchform">Process:
        
                <input type="text" value="{{ process_filter }}" name="process_filter"/>
            </td>
            <td class="searchform">Message:
        
                <input type="text" value="{{ message_filter }}" name="message_filter"/>
            </td>
            <td class="searchform">Raw Text:
                <input type="text" value="{{ raw_filter }}" name="raw_filter"/>
            </td>
        </tr>
        <tr>
            <td class="searchform">Source Host:
                <input type="text" value="{{ source_host_filter }}" name="source_host_filter"/></td>
            <td class="searchform">Source Port:
                <input type="text" value="{{ source_port_filter }}" name="source_port_filter"/></td>
            <td class="searchform">Dest. Host:
                <input type="text" value="{{ dest_host_filter }}" name="dest_host_filter"/></td>
            <td class="searchform">Dest. Port:
                <input type="text" value="{{ dest_port_filter }}" name="dest_port_filter"/></td>
        </tr>
        <tr>
            <td class="searchform">Source User:
                <input type="text" value="{{ source_user_filter }}" name="source_user_filter"/></td>
            <td class="searchform">Target User:
                <input type="text" value="{{ target_user_filter }}" name="target_user_filter"/></td>
            <td class="searchform">Command:
                <input type="text" value="{{ command_filter }}" name="command_filter"/></td>
            <td class="searchform">Session:
                <input type="text" value="{{ session_filter }}" name="session_filter"/></td>
        </tr>
        <tr>
            <td class="searchform">Action:
                <input type="text" value="{{ action_filter }}" name="action_filter"/></td>
            <td class="searchform">Interface:
                <input type="text" value="{{ interface_filter }}" name="interface_filter"/></td>
            <td class="searchform">Status:
                <input type="text" value="{{ status_filter }}" name="status_filter"/></td>
        </tr>
        <tr>
            <td class="searchform">Path (URI/file):
                <input type="text" value="{{ path_filter }}" name="path_filter"/></td>
            <td class="searchform">Parameters:
                <input type="text" value="{{ parameters_filter }}" name="parameters_filter"/></td>
            <td class="searchform">Referrer:
                <input type="text" value="{{ referrer_filter }}" name="referrer_filter"/></td>
        </tr>
        <tr>
            <td class="searchform">Event Type:
                <input type="text" value="{{ type_filter }}" name="type_filter"/></td>
            <td class="searchform">Start Date/Time:
                <input type="datetime-local" value="{{ starttime_filter }}" name="starttime_filter"</a></td>
            <td class="searchform">End Date/Time:
                <input type="datetime-local" value="{{ endtime_filter }}" name="endtime_filter"</a></td>
            <td class="searchsubmit">(YYYY-M-D H:M:S)</td>
        </tr>
        <tr><td class="searchsubmit"><input type="submit" name="submit" value="Search"/></td></tr>
    </table>
</form>

{% if event_list %}
    {% if is_paginated %}
        <div class="pagination">
            <span class="page-links">
                {% if page_obj.has_previous %}
                <a href="{{ request.get_path }}?log_source_filter={{ log_source_filter }}&process_filter={{ process_filter }}&source_host_filter={{ source_host_filter }}&dest_host_filter={{ dest_host_filter }}&source_user_filter={{ source_user_filter }}&target_user_filter={{ target_user_filter }}&action_filter={{ action_filter }}&command_filter={{ command_filter }}&session_filter={{ session_filter }}&interface_filter={{ interface_filter }}&status_filter={{ status_filter }}&path_filter={{ path_filter }}&parameters_filter={{ parameters_filter }}&referrer_filter={{ referrer_filter }}&type_filter={{ type_filter }}&message_filter={{ message_filter }}&raw_filter={{ raw_filter }}&starttime_filter={{ starttime_filter }}&endtime_filter={{ endtime_filter }}&page={{ page_obj.previous_page_number }}">previous</a>
                    &middot;
                {% endif %}
                <span class="page-current">
                    Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
                </span>
                {% if page_obj.has_next %}
                    &middot;
                    <a href="{{ request.get_path }}?log_source_filter={{ log_source_filter }}&process_filter={{ process_filter }}&source_host_filter={{ source_host_filter }}&source_port_filter={{ source_port_filter }}&dest_host_filter={{ dest_host_filter }}&dest_port_filter={{ dest_port_filter }}&source_user_filter={{ source_user_filter }}&target_user_filter={{ target_user_filter }}&action_filter={{ action_filter }}&command_filter={{ command_filter }}&session_filter={{ session_filter }}&interface_filter={{ interface_filter }}&status_filter={{ status_filter }}&path_filter={{ path_filter }}&parameters_filter={{ parameters_filter }}&referrer_filter={{ referrer_filter }}&type_filter={{ type_filter }}&message_filter={{ message_filter }}&raw_filter={{ raw_filter }}&starttime_filter={{ starttime_filter }}&endtime_filter={{ endtime_filter }}&page={{ page_obj.next_page_number }}">next</a>
                {% endif %}
            </span>
        </div>
    {% endif %}

    <table class="event">
        <tr><th>ID</th><th>Date Stamp</th>
            <th>Event<br>Type</th><th>Log<br>Source</th>
            <th>Src<br>Proc</th><th>#<br>Aggr</th>
            <th>Src<br>Host</th><th>Dest<br>Host</th>
            <th>Src<br>User</th><th>Trgt<br>User</th>
            <th>Cmd</th><th>Ses-<br>sion</th>
            <th>Act-<br>ion</th><th>Inter-<br>face</th>
            <th>Stat-<br>us</hr>
            <th>Path</th><th>Prm</th><th>Ref</th>
            <th class="left">Message</th></tr>
        {% for e in event_list %}
        <tr>
            <td><a class="event" href="{% url 'siem:logevent_detail' e.id %}">
                    {{ e.id }}</td>
            <td>{{ e.date_stamp }}</a></td>
            <td>{{ e.event_type }}</td>
            <td>{{ e.log_source }}</td>
            <td>{{ e.source_process }}</td>
            <td>{{ e.aggregated_events }}</td>
            <td>{{ e.source_host }}{% if e.source_port %}:{{ e.source_port }}{% endif %}</td>
            <td>{{ e.dest_host}}{% if e.dest_port %}:{{ e.dest_port }}{% endif %}</td>
            <td>{{ e.source_user }}</td>
            <td>{{ e.target_user }}</td>
            <td>{{ e.command }}</td>
            <td>{{ e.sessionid }}</td>
            <td>{{ e.action }}</td>
            <td>{{ e.interface }}</td>
            <td>{{ e.status}}</td>
            <td>{{ e.path }}</td>
            <td>{{ e.parameters }}</td>
            <td>{{ e.referrer }}</td>
            <td>{{ e.message }}</td>
            </a>
        </tr>
        {% endfor %}
    </table>

    {% if is_paginated %}
        <div class="pagination">
            <span class="page-links">
                {% if page_obj.has_previous %}
                    <a href="{{ request.get_path }}?log_source_filter={{ log_source_filter }}&process_filter={{ process_filter }}&source_host_filter={{ source_host_filter }}&dest_host_filter={{ dest_host_filter }}&source_user_filter={{ source_user_filter }}&target_user_filter={{ target_user_filter }}&action_filter={{ action_filter }}&command_filter={{ command_filter }}&session_filter={{ session_filter }}&interface_filter={{ interface_filter }}&status_filter={{ status_filter }}&path_filter={{ path_filter }}&parameters_filter={{ parameters_filter }}&referrer_filter={{ referrer_filter }}&type_filter={{ type_filter }}&message_filter={{ message_filter }}&raw_filter={{ raw_filter }}&starttime_filter={{ starttime_filter }}&endtime_filter={{ endtime_filter }}&page={{ page_obj.previous_page_number }}">previous</a>
                    &middot;
                {% endif %}
                <span class="page-current">
                    Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
                </span>
                {% if page_obj.has_next %}
                    &middot;
                    <a href="{{ request.get_path }}?log_source_filter={{ log_source_filter }}&process_filter={{ process_filter }}&source_host_filter={{ source_host_filter }}&source_port_filter={{ source_port_filter }}&dest_host_filter={{ dest_host_filter }}&dest_port_filter={{ dest_port_filter }}&source_user_filter={{ source_user_filter }}&target_user_filter={{ target_user_filter }}&action_filter={{ action_filter }}&command_filter={{ command_filter }}&session_filter={{ session_filter }}&interface_filter={{ interface_filter }}&status_filter={{ status_filter }}&path_filter={{ path_filter }}&parameters_filter={{ parameters_filter }}&referrer_filter={{ referrer_filter }}&type_filter={{ type_filter }}&message_filter={{ message_filter }}&raw_filter={{ raw_filter }}&starttime_filter={{ starttime_filter }}&endtime_filter={{ endtime_filter }}&page={{ page_obj.next_page_number }}">next</a>
                {% endif %}
            </span>
        </div>
    {% endif %}

{% else %}
    <p>No events.</p>
{% endif %}

{% endblock %}
